<%--
  Created by IntelliJ IDEA.
  User: Ailck
  Date: 2019/8/29
  Time: 9:35
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <script src="js/jquery-3.4.1.min.js"></script>
    <script>
        //fetch异步访问
        var test = function(){
            fetch('/json1')
                .then(function(response) {
                    return response.json();
                })
                .then(function(myJson) {
                    document.write(myJson.name+","+myJson.age);
                    console.log(myJson);
                })
                .catch(function (error) {
                    alert(error);
                });
        }
    </script>
</head>
<body>
<button onclick="test()">点击</button>
    a2
</body>
</html>
